package com.work.straighttalk;

import android.content.Context;
import android.content.IntentFilter;

import com.hyphenate.chat.EMClient;
import com.work.straighttalk.recevier.CallReceiver;

/**
 * Created by dllo on 16/3/11.
 */
public class StraightHelp {

    private CallReceiver callReceiver;
    private static StraightHelp instance = null;
    private Context appContext;


    public synchronized static StraightHelp getInstance() {
        if (instance == null) {
            instance = new StraightHelp();
        }
        return instance;
    }

    private StraightHelp() {
    }

    public void init(Context context) {
        appContext = context;
        setGlobalListeners();
    }

    protected void setGlobalListeners() {
        IntentFilter callFilter = new IntentFilter(EMClient.getInstance().callManager().getIncomingCallBroadcastAction());
        if (callReceiver == null) {
            callReceiver = new CallReceiver();
        }
        //注册通话广播接收者
        appContext.registerReceiver(callReceiver, callFilter);
    }
}
